package com.zqh.apiproductquery.controller;

import com.zqh.apiproductquery.service.ApiProductQueryService;
import com.zqh.myfmmall.result.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description :
 * @Author :kono淇杭哒、
 * @Create 2022-03-05 23:00
 */
@RestController
@RequestMapping("product/query")

public class ApiProductQueryController{
    @Resource
    private ApiProductQueryService apiProductQueryService;

    @GetMapping("retrieveLatest/{categoryId}")
    public Result retrieveLatest(@PathVariable("categoryId") String categoryId){
        return apiProductQueryService.latestProducts(categoryId);
    }

    @GetMapping("retrieveHighestSelling/{categoryId}")
    public Result retrieveHighestSelling(@PathVariable("categoryId") String categoryId){
        return apiProductQueryService.highestSellingProduct(categoryId);
    }

    @GetMapping("search/{pageNum}/{pageSize}")
    Result searchProduct(@RequestParam("key") String key,
                         @PathVariable("pageNum") Integer pageNum,
                         @PathVariable("pageSize") Integer pageSize){
        return apiProductQueryService.search(key, pageNum, pageSize);
    }



}
